package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.heart.domain.KingInventoryMaterialEntity;
import com.ly.heart.domain.dto.KingInventoryQueryDto;
import com.ly.heart.domain.dto.KingOrderMaterialQueryDto;
import com.ly.heart.domain.dto.KingReceiveNoticeMaterialQueryDto;
import com.ly.heart.domain.vo.KingPurchaseInventoryVo;
import com.ly.heart.domain.vo.KingSaleOutInventoryVo;
import com.ly.heart.domain.vo.OrderSumResult;
import com.ly.heart.mapper.KingInventoryMaterialMapper;
import com.ly.heart.service.IKingInventoryMaterialService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 金蝶-入库/出库明细Service业务层处理
 * @author cxl
 * @date 2024-07-13
 */
@Service
public class KingInventoryMaterialServiceImpl extends ServiceImpl<KingInventoryMaterialMapper, KingInventoryMaterialEntity> implements IKingInventoryMaterialService {

    @Resource
    private KingInventoryMaterialMapper kingInventoryMaterialMapper;

    @Override
    public List<KingPurchaseInventoryVo> getPurchaseInventoryList (KingInventoryQueryDto queryDto) {
        return kingInventoryMaterialMapper.getPurchaseInventoryList ( queryDto );
    }

    @Override
    public Integer queryTotalCount (KingInventoryQueryDto queryDto) {
        return kingInventoryMaterialMapper.queryTotalCount ( queryDto );
    }

    /**
     * 查询金蝶-入库/出库明细
     * @param id 金蝶-入库/出库明细ID
     * @return 金蝶-入库/出库明细
     */
    @Override
    public KingInventoryMaterialEntity selectKingInventoryMaterialEntityById (String id) {
        return kingInventoryMaterialMapper.selectKingInventoryMaterialEntityById ( id );
    }

    /**
     * 查询金蝶-入库/出库明细列表
     * @param kingInventoryMaterialEntity 金蝶-入库/出库明细
     * @return 金蝶-入库/出库明细
     */
    @Override
    public List<KingInventoryMaterialEntity> selectKingInventoryMaterialEntityList (KingInventoryMaterialEntity kingInventoryMaterialEntity) {
        return kingInventoryMaterialMapper.selectKingInventoryMaterialEntityList ( kingInventoryMaterialEntity );
    }

    /**
     * 新增金蝶-入库/出库明细
     * @param kingInventoryMaterialEntity 金蝶-入库/出库明细
     * @return 结果
     */
    @Override
    public int insertKingInventoryMaterialEntity (KingInventoryMaterialEntity kingInventoryMaterialEntity) {
        return kingInventoryMaterialMapper.insertKingInventoryMaterialEntity ( kingInventoryMaterialEntity );
    }

    /**
     * 修改金蝶-入库/出库明细
     * @param kingInventoryMaterialEntity 金蝶-入库/出库明细
     * @return 结果
     */
    @Override
    public int updateKingInventoryMaterialEntity (KingInventoryMaterialEntity kingInventoryMaterialEntity) {
        return kingInventoryMaterialMapper.updateKingInventoryMaterialEntity ( kingInventoryMaterialEntity );
    }

    /**
     * 批量删除金蝶-入库/出库明细
     * @param ids 需要删除的金蝶-入库/出库明细ID
     * @return 结果
     */
    @Override
    public int deleteKingInventoryMaterialEntityByIds (String[] ids) {
        return kingInventoryMaterialMapper.deleteKingInventoryMaterialEntityByIds ( ids );
    }

    /**
     * 删除金蝶-入库/出库明细信息
     * @param id 金蝶-入库/出库明细ID
     * @return 结果
     */
    @Override
    public int deleteKingInventoryMaterialEntityById (String id) {
        return kingInventoryMaterialMapper.deleteKingInventoryMaterialEntityById ( id );
    }

    @Override
    public List<KingInventoryMaterialEntity> selectMaterialByOrderIdAndMaterialId (KingOrderMaterialQueryDto queryDto) {
        return kingInventoryMaterialMapper.selectMaterialByOrderIdAndMaterialId ( queryDto );
    }

    @Override
    public OrderSumResult selectSumReceiptsNum (KingOrderMaterialQueryDto queryDto) {
        return kingInventoryMaterialMapper.selectSumReceiptsNum ( queryDto );
    }

    @Override
    public OrderSumResult selectSumReceiptsNumByReceiveNotice (KingReceiveNoticeMaterialQueryDto queryDto) {
        return kingInventoryMaterialMapper.selectSumReceiptsNumByReceiveNotice ( queryDto );
    }

    @Override
    public List<KingSaleOutInventoryVo> getSaleOutInventoryList (KingInventoryQueryDto queryDto) {
        return kingInventoryMaterialMapper.getSaleOutInventoryList ( queryDto );
    }

    @Override
    public Integer getSaleOutInventoryCount ( KingInventoryQueryDto queryDto ) {
        return kingInventoryMaterialMapper.getSaleOutInventoryCount ( queryDto );
    }

    /**
     * 通过物料、批号、类型=出库、出库时间查询本月前的出库记录
     * @param kingInventoryMaterialEntity
     * @return
     */
    @Override
    public List<KingInventoryMaterialEntity> queryListByCostAdjustment (KingInventoryMaterialEntity kingInventoryMaterialEntity) {
        List<KingInventoryMaterialEntity> inventoryMaterialEntities = kingInventoryMaterialMapper.queryListByCostAdjustment ( kingInventoryMaterialEntity );
        return inventoryMaterialEntities;
    }

    /**
     * 通过出库单Id查询销售出库单明细列表
     * @param inventoryId
     * @return
     */
    @Override
    public List<KingInventoryMaterialEntity> querySaleInventoryList (String inventoryId) {
        List<KingInventoryMaterialEntity> kingInventoryMaterialEntities = kingInventoryMaterialMapper.querySaleInventoryList ( inventoryId );
        return kingInventoryMaterialEntities;
    }
}
